<span page-title ng-model="activationKey">{{ 'Details for Activation Key:' | translate }} {{ activationKey.name }}</span>

<div bst-alert="info">
  <span translate>
    This activation key may be used during system registration. For example:
  </span>
  <p translate>
    subscription-manager register --org="{{ activationKey.organization.label }}" --activationkey="{{ activationKey.name }}"
  </p>
</div>

<div data-extend-template="layouts/two-column-details.html">
  <div data-block="left-column">
    <h4 translate>Basic Information</h4>

    <dl class="dl-horizontal dl-horizontal-left">
      <dt translate>Name</dt>
      <dd bst-edit-text="activationKey.name"
          readonly="denied('edit_activation_keys', activationKey)"
          on-save="save(activationKey)">
      </dd>

      <dt translate>Description</dt>
      <dd bst-edit-textarea="activationKey.description"
          readonly="denied('edit_activation_keys', activationKey)"
          on-save="save(activationKey)">
      </dd>

      <dt translate>Host Limit</dt>
      <dd bst-edit-custom="activationKey.max_hosts"
          formatter="unlimitedFilter"
          formatter-options="activationKey.unlimited_hosts"
          readonly="denied('edit_activation_keys', activationKey)"
          on-save="save(activationKey)">

        <div class="form input">
          <div>
            <span translate>
              Unlimited Content Hosts:
            </span>
            <input type='checkbox' ng-model="activationKey.unlimited_hosts"/>
          </div>
          <div ng-hide="activationKey.unlimited_hosts" >
            <span translate>
              Limit:
            </span>
            <input ng-model="activationKey.max_hosts"
                   name="max_hosts"
                   type="number"
                   min="1"
                   ng-required="!activationKey.unlimited_hosts"
                   tabindex="2"/>
          </div>
        </div>
      </dd>


      <div class="divider"></div>
      <h4 translate>System Purpose</h4>

      <dt translate>Service Level</dt>
      <dd bst-edit-select="activationKey.service_level"
          readonly="denied('edit_activation_keys', activationKey)"
          selector="activationKey.service_level"
          options="serviceLevels()"
          options-format="option for option in options"
          deletable="activationKey.service_level && activationKey.service_level != ''"
          on-delete="clearServiceLevel()"
          on-save="save(activationKey)">
      </dd>

      <dt translate>Usage Type</dt>
      <dd bst-edit-select="activationKey.purpose_usage"
          readonly="denied('edit_activation_keys', activationKey)"
          selector="activationKey.purpose_usage"
          options="purposeUsages()"
          options-format="option for option in options"
          deletable="true"
          on-delete="clearUsage()"
          on-save="save(activationKey)">
      </dd>


      <dt translate>Role</dt>
      <dd bst-edit-select="activationKey.purpose_role"
          readonly="denied('edit_activation_keys', activationKey)"
          selector="activationKey.purpose_role"
          options="purposeRoles()"
          options-format="option for option in options"
          deletable="true"
          on-delete="clearRole()"
          on-save="save(activationKey)">
      </dd>

      <dt translate>Add ons</dt>
      <dd bst-edit-multiselect="activationKey.purpose_addons"
          readonly="denied('edit_activation_keys', activationKey) || purposeAddonsCount === 0"
          options="purposeAddons()"
          formatter="arrayToString"
          deletable="true"
          on-delete="clearAddOns()"
          selector="activationKey.purpose_addons"
          on-save="savePurposeAddons(activationKey)">
      </dd>

    </dl>
  </div>

  <div data-block="right-column">
    <h4 translate>Activation Key Content</h4>

    <dl class="dl-horizontal dl-horizontal-left">
      <dt translate>Release Version</dt>
      <dd bst-edit-select="activationKey.release_version"
          readonly="denied('edit_activation_keys', activationKey)"
          selector="activationKey.release_version"
          options="releaseVersions()"
          options-format="option for option in options"
          deletable="activationKey.release_version && activationKey.release_version != ''"
          on-delete="clearReleaseVersion()"
          on-save="save(activationKey)">
      </dd>

      <dt bst-feature-flag="lifecycle_environments">
        <span translate>Environment</span>
      </dt>
      <dd bst-feature-flag="lifecycle_environments">
        <div path-selector="environments"
             ng-model="activationKey.environment"
             mode="singleSelect"
             selection-required="selectionRequired"
             disabled="denied('edit_activation_keys', activationKey)"
             disable-trigger="disableEnvironmentSelection">
        </div>
      </dd>

      <dt bst-feature-flag="lifecycle_environments">
        <span translate>Content View</span>
      </dt>
      <dd bst-feature-flag="lifecycle_environments">
        <div bst-edit-select="activationKey.content_view.name"
             readonly="denied('edit_activation_keys', activationKey) || activationKey.environment === undefined || activationKey.environment === null"
             selector="activationKey.content_view.id"
             options="contentViews()"
             on-cancel="cancelContentViewUpdate()"
             on-save="saveContentView(activationKey)"
             deletable="activationKey.content_view"
             on-delete="resetEnvironment(activationKey)"
             edit-trigger="editContentView">
        </div>

        <div bst-alert="info" ng-show="editEnvironment">
          <p translate>You must select a content view in order to save your environment.</p>
        </div>
        <div bst-alert="info" ng-show="editContentView && !editEnvironment">
          <p translate>You must select a new content view before your change of environment can be saved. Use the cancel button on content view selection to revert your environment selection.</p>
        </div>
      </dd>
    </dl>
  </div>
</div>

